package com.leo.apptest.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.leo.apptest.R;

public class LeakCanaryActivity extends AppCompatActivity implements View.OnClickListener{
    private static Activity activity;
    private Button mBtTest;
    private Button mBtThread;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leak_canary);
        mBtTest = (Button)findViewById(R.id.btTest);
        mBtThread = (Button)findViewById(R.id.btThread);

        mBtTest.setOnClickListener(this);
        mBtThread.setOnClickListener(this);

        System.out.println("sdadsadsd");

    }

    private void setActivity(){
        activity = this;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btTest:
                setActivity();
                break;
            case R.id.btThread:
                spawnThread();
                break;
        }
    }

    private void spawnThread(){
        new Thread(){
            @Override
            public void run() {
                super.run();
                while (true);
            }
        }.start();
    }
}
